#ifndef _OCPP_GribLevel_H__
#define _OCPP_GribLevel_H__

#include "GribDefine.h"
#include <iomanip>

namespace OCPP
{
	class GribLevel
	{
	public:
		GribLevel(double t1, double t2);
		~GribLevel();

		//
		String units = "";
		String levelUnits = "";

		using LevelBound = std::tuple<double, double>;
		LevelBound _levelBound;

		bool operator < (const GribLevel& lhs) const
		{
			auto [t1, t2] = _levelBound;
			auto [t11, t22] = lhs._levelBound;

			if (t1 == t11)
			{
				return t2 < t22;
			}

			return t1 < t11;
		}

		bool operator == (const GribLevel& lhs) const
		{
			return std::get<0>(_levelBound) == std::get<0>(lhs._levelBound)
				&& std::get<1>(_levelBound) == std::get<1>(lhs._levelBound);
		}

		const String toString() const
		{
			auto [t1, t2] = _levelBound;
			StringStream sstream;

			if (fabs(t1 - (int)t1) > 0.0f)
			{
				sstream << std::setprecision(3) << t1;
			}
			else
			{
				sstream << (int)t1;
			}
			if (t2 != 0.0f)
			{
				if (fabs(t2 - (int)t2) > 0.0f)
				{
					sstream << "_" << std::setprecision(3) << t2;
				}
				else
				{
					sstream << "_" << (int)t2;
				}

			}
			return sstream.str();
		}
	};
}


#endif // !_OCPP_GribReader_H__
